import React from 'react';
import style from './index.less';
import { Row, Col, Form, Icon, Input, Button } from 'antd';
const FormItem = Form.Item;


class Login extends React.Component{


    submit = () => {
        this.props.form.validateFields(
            (err) => {
                if (!err) {
                    console.info('success');
                    this.props.history.push('/home/dashboard');
                }
            },
        );
    }

    render(){
        const {getFieldDecorator} = this.props.form;
        console.log('login');
        return (
            <Row type='flex' justify='center' className={style.form}>
                <Col className={style.login}>
                    <Form className={style.test}>
                        <FormItem>{
                            getFieldDecorator('username', {
                                rules: [{
                                    required: true,
                                    message: 'Please input your name',
                                }],
                            })(<Input prefix={<Icon type="user" style={{ color: 'rgba(0,0,0,.25)' }} />} type="text" placeholder='账号'/>)
                        }


                        </FormItem>
                        <FormItem>
                            {
                                getFieldDecorator('password', {
                                    rules:[
                                        {
                                            required: true,
                                            message: 'Please input your password',
                                        }
                                    ]
                                })(
                                    <Input prefix={<Icon type="lock" style={{ color: 'rgba(0,0,0,.25)' }} />} type="password" placeholder='密码'/>
                                )
                            }

                        </FormItem>
                        <Button type="primary" className={style.submit} onClick={this.submit}>登录</Button>
                    </Form>
                </Col>
            </Row>

        )
    }
}
export default Form.create()(Login);